package org.java.guawa;

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;

import java.util.HashSet;
import java.util.List;

public class DoJoin {
	public static void main(String[] args) {
		
		List<String> strList1 = newArrayList(); 
		List<String> strList2 = newArrayList(); 
				
//		Multiset<String> strList1 = HashMultiset.create();  
//		
//		Multiset<String> strList2 = HashMultiset.create(); 		
		
		long tagTime = System.currentTimeMillis();
		for (int i = 0; i < 100000; i++) {
//			strSet1.add("aaa>>" + i);			
			strList1.add("aaa>>" + i);
		}
		
		for (int i = 0; i < 10000000; i++) {			
//			strSet2.add("aaa>>" + (12 - i));
			strList2.add("aaa>>" + (12 - i));
		}		
				
		System.out.println(System.currentTimeMillis()-tagTime);
		
		tagTime = System.currentTimeMillis();
		
		HashSet<String> strSet1 = newHashSet(strList1);
		HashSet<String> strSet2 = newHashSet(strList2);
		System.out.println(System.currentTimeMillis()-tagTime);

		tagTime = System.currentTimeMillis();
		strSet1.retainAll(strSet2);
		System.out.println(System.currentTimeMillis()-tagTime);
		System.out.println("交集大小：" + strSet1.size());
	}
}
